<template>
  <div>
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column
        prop="studentName"
        label="学员名称"
        show-overflow-tooltip
      >
        <template slot-scope="{ row }">
          <span>{{ row.studentName }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="创建时间" width="180">
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="{ row }">
          <el-button-group>
            <el-button type="danger" size="mini" @click="handleDelete(row)"
              >删除</el-button
            >
          </el-button-group>
        </template>
      </el-table-column>
      <div slot="empty" class="emptyBg">
        <el-empty :image-size="200"></el-empty>
      </div>
    </el-table>
  </div>
</template>
<script>
export default {
  data() {
    return {
      listQuery: {
        page: 1,
        limit: 10,
        classesId: '',
      },
      tableData: [],
    }
  },
  mounted() {
    this.getList()
    this.$bus.$on('refreshEduClassesStudentList', (v) => {
      if (v) {
        Object.assign(this.listQuery, v)
      }
      this.getList()
    })
  },
  beforeDestroy() {
    this.$bus.$off('refreshEduClassesStudentList')
  },
  methods: {
    async getList() {
      let { classesId } = this.$route.query
      this.listQuery.classesId = classesId
      let res = await this.$store.dispatch(
        'queryEduClassesStudent',
        this.listQuery,
      )
      this.tableData = res.data
    },
    handleDelete(row) {
      this.deleteTips(async () => {
        await this.$store.dispatch('deleteEduClassesStudent', row)
        this.getList()
      })
    },
    handleUser(row) {
      // console.log(row)
    },
  },
}
</script>